#ifndef __STORMWIDGET_STORMWIDGET_UILIBRARY_CCONTROLUI_CONTROLUI_H
#define __STORMWIDGET_STORMWIDGET_UILIBRARY_CCONTROLUI_CONTROLUI_H

#include "UIDefinition.h"

class CPaintManagerUI;

typedef CControlUI* (CALLBACK* FINDCONTROLPROC)(CControlUI*, LPVOID);

class CControlUI:public INotifyUI
{
public:
	CControlUI(void);
	virtual ~CControlUI(void);
public:
	virtual CStdString GetName() const;
	virtual void SetName(LPCTSTR pstrName);
	virtual LPVOID GetInterface(LPCTSTR pstrName);
	virtual bool Activate();
	virtual CControlUI* GetParent() const;
	virtual CStdString GetText() const;
	virtual void SetText(LPCTSTR pstrText);
	virtual CStdString GetToolTip() const;
	virtual void SetToolTip(LPCTSTR pstrText);
	virtual TCHAR GetShortcut() const;
	virtual void SetShortcut(TCHAR ch);
	virtual UINT_PTR GetTag() const;
	virtual void SetTag(UINT_PTR pTag);
	virtual void SetFocus();
	virtual bool IsVisible() const;
	virtual bool IsEnabled() const;
	virtual bool IsFocused() const;
	virtual void SetVisible(bool bVisible = true);
	virtual void SetEnabled(bool bEnable = true);
	virtual CControlUI* FindControl(FINDCONTROLPROC Proc,LPVOID pData,UINT uFlags);
	virtual CPaintManagerUI* GetManager() const;
	virtual void SetManager(CPaintManagerUI* pManager,CControlUI* pParent);
	virtual RECT GetPos() const;
	virtual void SetPos(RECT rc);
	virtual UINT GetControlFlags() const;
	virtual void Init();
	virtual void Event(TEventUI& event);
	virtual void Notify(TNotifyUI& msg);
	virtual void SetAttribute(LPCTSTR pstrName,LPCTSTR pstrValue);
	virtual LPCTSTR GetClass() const = 0;
	virtual SIZE EstimateSize(SIZE szAvailable) = 0;
	virtual void DoPaint(HDC hDC,const RECT& rcPaint) = 0;
	CControlUI* ApplyAttributeList(LPCTSTR pstrList);
	void Invalidate();
	void UpdateLayout();

public:
	CPaintManagerUI* m_pManager;
	CControlUI* m_pParent;
	TCHAR m_chShortcut;
	CStdString m_sName;
	CStdString m_sText;
	CStdString m_sToolTip;
	UINT_PTR m_pTag;
	RECT m_rcItem;
	bool m_bVisible;
	bool m_bEnabled;
	bool m_bFocused;

};
#endif// __STORMWIDGET_STORMWIDGET_UILIBRARY_CCONTROLUI_CONTROLUI_H